<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="test1"></div>
  <div id="test2"></div>
  <div id="test3"></div>
  <!-- 引入react核心库 -->
  <script src="https://unpkg.com/react@16/umd/react.development.js"></script>
  <!-- 用于支持react操作DOM -->
  <script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
  <!-- 用于将jsx转为js -->
  <script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>
  <!-- 用于全局引入PropTypes，对标签属性进行限制 -->
  <script src="https://unpkg.com/prop-types@15.6/prop-types.js"></script>
  
  <script type="text/babel">
    
    function Person (props){
      const {name,age,sex}=props;

      return (
          <ul>
            <li>姓名：{name}</li>
            <li>性别：{sex}</li>
            <li>年龄：{age}</li>
          </ul>
        )
    }

    //限制传入的props标签属性
    Person.propTypes={
      name:PropTypes.string.isRequired,//限制name为必须传，且为string类型
      sex:PropTypes.string,
      age:PropTypes.number,
      speak:PropTypes.func,//限制speak类型为函数
    }
    //设置默认的props标签属性
    Person.defaultProps={
      sex:'男',
      age:18
    }
    
    //组件外部传值
    ReactDOM.render(<Person name='Tom'/>,document.getElementById('test1'))
    
  </script>
</body>
</html>